#! /bin/bash

# check oh-my-posh installation
if command -v oh-my-posh >/dev/null 2>&1; then
    echo 'oh-my-posh' has been installed
else
    echo 'oh-my-posh' is not installed，install it.
    curl -s https://ohmyposh.dev/install.sh | bash -s
fi

# download posh theme
mkdir -p $HOME/.cache/oh-my-posh/themes
wget https://raw.gitcode.com/jamesfancy/linux-configs/raw/oh-my-posh/jamesfan.omp.json -O $HOME/.cache/oh-my-posh/themes/jamesfan.omp.json

# check .profile_posh
if [ `grep -c '.profile_posh' $HOME/.profile` -eq '0' ]; then
    echo -e >> $HOME/.profile
    echo 'if [ -f "$HOME/.profile_posh" ]; then . "$HOME/.profile_posh"; fi' >> $HOME/.profile
fi

if [ ! -f "$HOME/.profile_posh" ]; then
    wget https://raw.gitcode.com/jamesfancy/linux-configs/raw/oh-my-posh/.profile_posh -O $HOME/.profile_posh
fi
